package net.pimpas.web.jsf.components.ajax.poolsize;

import javax.faces.context.FacesContext;

import net.pimpas.web.jsf.components.UIComponentPimpasBase;
import net.pimpas.web.jsf.components.ajax.UIAjax;

public class UIAjaxPoolSize extends UIComponentPimpasBase {
	
	public static final String COMPONENT_TYPE			= UIAjax.COMPONENT_TYPE+".poolsize";
	public static final String COMPONENT_FAMILY			= UIAjax.COMPONENT_FAMILY+".poolsize";
	public static final String COMPONENT_RENDER_TYPE	= UIAjax.COMPONENT_RENDER_TYPE+".poolsize";
	
	public static final Integer DEFAULT_POOL_SIZE		= 10;
	
	private Integer value;
	
	@Override
	public Object saveState(FacesContext context) {
		Object[] ob = new Object[2];
		ob[0] = super.saveState(context);
		ob[1] = this.getValue();
		
		return ob;
	}
	
	@Override
	public void restoreState(FacesContext context, Object state) {
		Object[] ob = (Object[]) state;
		super.restoreState(context, ob[0]);
		this.setValue((Integer) ob[1]);
	}

	@Override
	public String getRendererType() {
		return COMPONENT_RENDER_TYPE;
	}

	@Override
	public String getFamily() {
		return COMPONENT_FAMILY;
	}

	public Integer getValue() {
		return value;
	}

	public void setValue(Integer value) {
		this.value = value;
	}
}